package drds.server.execute_engine.data_handling;

import drds.server.execute_engine.data_handling.tmp.RowDataSorter;
import drds.server.net.packet.RowDataPacket;

public class RangRowDataPacketSorter extends RowDataSorter {
	public RangRowDataPacketSorter(OrderByColum[] orderByColums) {
		super(orderByColums);
	}

	public boolean ascDesc(int orderByColumIndex) {
		if (this.orderByColums[orderByColumIndex].orderType == OrderByColum.ORDER_TYPE_ASC) {// 升序
			return true;
		}
		return false;
	}

	public int compareRowData(RowDataPacket $left, RowDataPacket $right, int orderByColumIndex) {
		byte[] left = $left.fieldBytesList.get(this.orderByColums[orderByColumIndex].colum.columIndex);
		byte[] right = $right.fieldBytesList.get(this.orderByColums[orderByColumIndex].colum.columIndex);
		return compareObject(left, right, this.orderByColums[orderByColumIndex]);
	}
}